export default {
	data() {
		return {
			tabs: [],
			current: 0,
			limit: 10,
			goodsList: [],
		};
	},
	async onLoad() {
		await this.getCateList()
	},
	methods: {
		// 获取分类
		async getCateList() {
			var res = await this.$get('server/index/getshopgoodstype', {
				page: 1,
				limit: 10,
				type: 2
			});
			if (res.errcode != 0) {
				this.$toast(res.errmsg);
				return;
			}
			this.tabs = res.list
			this.$refs.paging.reload()
		},
		// 商品列表
		async getGoodsList(pageNo, pageSize) {
			var res = await this.$get('server/index/getshopgoods', {
				typeid: this.tabs[this.current].id,
				page: pageNo,
				limit: pageSize,
			});
			if (res.errcode != 0) {
				this.$toast(res.errmsg);
				this.$refs.paging.complete(false);
				return;
			}
			this.$refs.paging.complete(res.list);
		},
		// 跳转详情
		onDetail(item) {
			this.$navTo('pages/shop/detail/detail', {
				goodsId: item.id
			})
		}
	}
}
